package 区间最大公约数;

import java.io.*;
import java.util.*;

public class Main {
    static int N = 500010, n, m;
    static long[] w = new long[N];
    static Node[] tr = new Node[4 * N];

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] s = in.readLine().split(" ");
        n = Integer.parseInt(s[0]);
        m = Integer.parseInt(s[1]);
        String[] str = in.readLine().split(" ");
        for (int i = 1; i <= n; i++) {
            w[i] = Long.parseLong(str[i - 1]);
        }
        build(1, 1, n);
        while (m-- > 0) {
            String[] s1 = in.readLine().split(" ");
            int l = Integer.parseInt(s1[1]);
            int r = Integer.parseInt(s1[2]);
            if (s1[0].equals("Q")) {
                Node res1 = query(1, 1, l), res2 = new Node(0, 0, 0, 0);
                if (l + 1 <= r) {
                    res2 = query(1, l + 1, r);
                }
                out.write(Math.abs(gcd(res1.sum, res2.d)) + "\n");
            } else {
                long d = Long.parseLong(s1[3]);
                modify(1, l, d);
                if (r + 1 <= n) {
                    modify(1, r + 1, -d);
                }
            }
        }
        out.flush();
    }

    private static void modify(int u, int x, long v) {
        if (tr[u].l == x && tr[u].r == x) {
            tr[u].sum += v;
            tr[u].d += v;
        } else {
            int mid = tr[u].l + tr[u].r >> 1;
            if (x <= mid) {
                modify(u << 1, x, v);
            } else {
                modify(u << 1 | 1, x, v);
            }
            pushup(u);
        }
    }

    private static Node query(int u, int l, int r) {
        if (tr[u].l >= l && tr[u].r <= r) {
            return tr[u];
        }
        int mid = tr[u].l + tr[u].r >> 1;
        if (r <= mid) {
            return query(u << 1, l, r);
        } else if (l >= mid + 1) {
            return query(u << 1 | 1, l, r);
        } else {
            Node ret = new Node();
            Node res1 = query(u << 1, l, r);
            Node res2 = query(u << 1 | 1, l, r);
            pushup(ret, res1, res2);
            return ret;
        }
    }

    private static void build(int u, int l, int r) {
        if (l == r) {
            long b = (long) w[l] - w[l - 1];
            tr[u] = new Node(l, r, b, b);
        } else {
            tr[u] = new Node(l, r);
            int mid = l + r >> 1;
            build(u << 1, l, mid);
            build(u << 1 | 1, mid + 1, r);
            pushup(u);
        }
    }

    private static void pushup(Node root, Node l, Node r) {
        root.sum = l.sum + r.sum;
        root.d = gcd(l.d, r.d);
    }

    private static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    private static void pushup(int u) {
        pushup(tr[u], tr[u << 1], tr[u << 1 | 1]);
    }
}

class Node {
    int l, r;
    long sum, d;

    public Node() {

    }

    public Node(int l, int r) {
        this.l = l;
        this.r = r;
    }

    public Node(int l, int r, long sum, long d) {
        this.l = l;
        this.r = r;
        this.sum = sum;
        this.d = d;
    }
}
